{block name=classterm-tree-list} {if $classterm_list}
<form class="form-horizontal" id="attendance-roll-form" role="form" accept-charset="UTF-8" action="" method="post">
    <input type="hidden" value="GetAttendaceTable" name="action" />
    <input type="hidden" value="/admin/includes/processes/processes-enrolment.php" name="url" />
    <input type="hidden" name="formToken" value="{$token}" />
    <input type="hidden" name="term_object_id" id="sel_term_object_id" value="{if $terms.0.term_object_id}{$terms.0.term_object_id}{else}{$sel_term_object_id}{/if}" />
    <input type="hidden" name="term_name" value="{if $terms}{$terms.0.term_name} - {$terms.0.term_region}{else}{$term_name}{/if}" />
    <input type="hidden" name="class_name" value="" id="class_name" />
    <div class="form-group">
        <label for="week" class="col-sm-2 control-label">学期周</label>
        <div class="col-sm-8">
            <select name="week" id="week" class="form-control" onchange="$('#attendance-roll-wrapper').html('')">
                {if $terms} {assign var='sel_weeks' value=$terms.0.weeks} {assign var='sel_curweek' value=$terms.0.current_week} {else} {assign var='sel_weeks' value=$weeks} {assign var='sel_curweek' value=$current_week} {/if} {for $i=1 to $sel_weeks}
                <option value="{$i}" {if $i eq $sel_curweek}selected="selected" {/if}>第 {$i} 周{if $i eq $sel_curweek}(本周){/if}</option>
                {/for}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="classterm-select" class="col-sm-2 control-label">课程</label>
        <div class="col-sm-8">
            <select name="class_object_id" id="class_object_id" class="form-control" onchange="$('#class_name').val( $(this).find('option:selected').text() ); $('#attendance-roll-wrapper').html('');">
                {assign var=weekdays value=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday', 'Saturday']} {foreach from=$classterm_list key=kloc item=location}
                <optgroup label="{$location.location_name}">
                    {foreach $weekdays as $weekday} {assign var=classes value=$location.weekdays.$weekday} {if $classes} {foreach from=$classes key=classoid item=class}
                    <option value="{$class.class_object_id}">{$class.class_name} | {$class.agegroup_name}</option>
                    {/foreach} {/if} {/foreach} {/foreach}
            </select>
        </div>
    </div>
    <div class="error-alert" style="display:none;">
        <div class="alert alert-danger fade in ">
            <button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
            <strong></strong>
        </div>
    </div>
    <div class="text-center">
        <button type="submit" onclick="" class="btn btn-default">查看</button>
    </div>
</form>
<hr>
<div id="attendance-roll-wrapper">
    {include file="table-attendance.tpl"}
</div>
{else}
<div class="well">
    <h3>该学期没有课程。</h3>
</div>
{/if} {/block}
<script type="text/javascript">
$(function() {
    $('#attendance-roll-form').validate();
    $('#class_object_id').trigger("change");
});
</script>
